<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('动态成本管理')"/>
    <th:block th:include="include :: bootstrap-editable-css"/>
    <th:block th:include="include :: datetimepicker-css"/>

</head>
<style>

    select {
        padding-top: 3px !important;
    }

    .select-list {
        margin-top: 5px !important;
    }

    .select-list li p {
        width: auto !important;
        margin-top: 7px !important;
    }

    .text {
        line-height: 34px;
        margin-bottom: 20px;
        white-space: nowrap;
        text-align: right;
    }

    .modal-body {
        padding: 15px !important;
    }

    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

    .form-control {
        border-radius: 5px;
    }

    .right-fixed-table-columns {
        width: auto !important;
    }

    .container-div .row {
        height: auto !important;
    }

    .modal-dialog {
        margin: 10% auto;
    }

    input[name='year'], input[name='month'] {
        background-color: #eee !important;
    }

    td {
        border: 1px solid #cccccc !important;
        border-top: 1px solid #cccccc !important;

    }


</style>
<body class="gray-bg">
<div class="container-div">
    <input type="hidden" id="maxDateYear" th:value="${maxDate.year}">
    <input type="hidden" id="maxDateMonth" th:value="${maxDate.month}">
    <button type="button" class="btn btn-primary btn-table" style="display: none;" data-toggle="modal"
            data-target="#myModal6">
    </button>
    <div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">日期选择</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <label class="col-sm-3 control-label text">年份：</label>
                        <div class="col-sm-8">
                            <input name="years" id="years" class="form-control noselect2" disabled>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-3 control-label text">月份：</label>
                        <div class="col-sm-8">
                            <select name="months" id="months" class="form-control noselect2">
                                <option value="">请选择</option>
                                <option th:each="month : ${month}" th:text="${month.name+'月'}"
                                        th:value="${month.name}"></option>
                            </select>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="table_add()">保存</button>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="region-form">
                <input id="companyId" name="companyId" type="hidden" th:value="${companyId}"/>
                <input id="proId" name="proId" type="hidden" th:value="${proId}"/>
                <input id="buildingId" name="buildingId" type="hidden" th:value="${buildingId}"/>

                <div class="select-list">
                    <ul>
                        <li>
                            年：<input type="text" name="year" id="year" readonly="readonly"/>
                        </li>
                        <li>
                            月：<input type="text" name="month" id="month" readonly="readonly"/>
                        </li>
                        <li>
                            编码编号：<input type="text" name="codeNum" id="codeNum"/>
                        </li>
                        <li>
                            编码名称：<input type="text" name="codeName" id="codeName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                        <li style="float: right;">
                            <a id='submit' class="btn btn-success btn-rounded btn-sm" onclick="submit()"><i
                                    class="fa fa-edit"></i>&nbsp;提交</a>
                        </li>
                    </ul>
                </div>
            </form>

        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-height="700"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "costSummary";
    $(function () {
        var date = new Date();
        $(".btn-table").click();
        $("#years").val(date.getFullYear());
    });

    var summaryId;
    var codeId;
    var cumulative;
    var theory;
    var summaryMonthId;
    var changeCost;
    var changeIncome;
    var currentTotal;
    var currentTheoryTotal;
    var currentChangeCost;
    var currentChangeIncome;

    function queryRegionList() {

        var options = {
            url: prefix + "/addList",
            id: 'bootstrap-table',
            uniqueId: 'codeId',
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            fixedColumns: true,
            fixedNumber: 4,
            pageList: [10, 25, 50, 75, 100],
            onLoadSuccess: function (data) {
                // if (Number($("#maxDateYear").val()) > 0) {
                //     if (Number($("#maxDateYear").val()) > Number($("#years").val()) || Number($("#maxDateMonth").val()) > Number($("#months").val())) {
                //         $("input").attr('disabled', 'disabled');
                //         $("#submit").hide();
                //     }
                // }
                var count = readOnly();
                for (var i = 0; i < data.rows.length; i++) {
                    if (count > 0) {
                        $("#number" + i).attr("disabled", "disabled");
                        $("#containTaxUnivalent" + i).attr("disabled", "disabled");
                        $("#taxRate" + i).attr("disabled", "disabled");
                    }
                }
            },
            onClickRow: function (row, $element) {
                summaryId = row.summaryId;
                codeId = row.codeId;
                cumulative = row.cumulative;
                theory = row.theory;
                summaryMonthId = row.summaryMonthId;
                changeCost = row.changeCost;
                changeIncome = row.changeIncome;
                currentTotal = row.currentTotal;
                currentTheoryTotal = row.currentTheoryTotal;
                currentChangeCost = row.currentChangeCost;
                currentChangeIncome = row.currentChangeIncome;
            },
            columns: [
                {
                    field: 'codeNum',
                    title: '编码编号',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<div style="width: 60px;">' + value + '</div>'
                    }
                },
                {
                    field: 'codeName',
                    title: '编码名称',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<div style="width: 100px;">' + value + '</div>'
                    }
                },
                {
                    field: 'codeFeature',
                    title: '特征',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value == null) {
                            value = ""
                        }
                        return '<div style="width: 100px;">' + value + '</div>'
                    }

                },
                {
                    field: 'codeUnit',
                    title: '单位',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value == null) {
                            value = ""
                        }
                        return '<div style="width: 50px;">' + value + '</div>'
                    }
                },
                {
                    field: 'number',
                    title: '目标数量',
                    align: 'center',
                    formatter: function (value, row, index) {

                        return '<input type="number" class="form-control" id="number' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" style="width: 100px">'
                    }
                },
                {
                    field: 'containTaxUnivalent',
                    title: '目标单价',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="containTaxUnivalent' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" style="width: 100px">'
                    }
                },
                {
                    field: 'targetCost',
                    title: '目标成本',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="targetCost' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'currentChangeCost',
                    title: '当期变动成本',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentChangeCost' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '"  style="width: 100px">'
                    }

                },
                {
                    field: 'changeCost',
                    title: '变动成本',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="changeCost' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled  style="width: 100px">'
                    }

                },
                {
                    field: 'reviseCost',
                    title: '修订成本',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="reviseCost' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'currentChangeIncome',
                    title: '当期变动收入',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentChangeIncome' + index + '" onblur="changeData(' + index + ',this)" value="' + Number(value) + '"  style="width: 100px">'
                    }

                },
                {
                    field: 'changeIncome',
                    title: '变动收入',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="changeIncome' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }

                },
                {
                    field: 'profitChange',
                    title: '利润变动',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="profitChange' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }

                },
                {
                    field: 'taxRate',
                    title: '税率(%)',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="taxRate' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" style="width: 100px">'
                    }
                },
                {
                    field: 'inputTax',
                    title: '进项税',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="inputTax' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'currentNumber',
                    title: '当期数量',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentNumber' + index + '"  onblur="changeData(' + index + ')" value="' + Number(value) + '"  style="width: 100px">'
                    }
                },
                {
                    field: 'currentUnivalent',
                    title: '当期单价',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentUnivalent' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '"  style="width: 100px">'
                    }
                },
                {
                    field: 'currentTotal',
                    title: '当期总价',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentTotal' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'cumulative',
                    title: '截止本期累计',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="cumulative' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '"disabled style="width: 100px">'
                    }

                },
                {
                    field: 'currentTheoryNumber',
                    title: '当期理论数量',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentTheoryNumber' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '"  style="width: 100px">'
                    }
                },
                {
                    field: 'currentTheoryUnivalent',
                    title: '当期理论单价',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentTheoryUnivalent' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'currentTheoryTotal',
                    title: '当期理论总价',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="currentTheoryTotal' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'theory',
                    title: '截止本期理论',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="theory' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }

                },
                {
                    field: 'surplus',
                    title: '截止本期结余',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="surplus' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                },
                {
                    field: 'allowance',
                    title: '余量',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<input type="number" class="form-control" id="allowance' + index + '" onblur="changeData(' + index + ')" value="' + Number(value) + '" disabled style="width: 100px">'
                    }
                }
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var html = '<div><a class="btn btn-success btn-xs" href="#"onclick="sumex(\'' + index + '\')"><i class="fa fa-edit"></i>提交</a></div>';
                //         // if (row.summaryId != null && row.codeId != null) {
                //         //     html = '<div style="width: 100px;"><a class="btn btn-success btn-xs" href="#"onclick="sumex(\'' + index + '\')"><i class="fa fa-edit"></i>提交</a><a class="btn btn-danger btn-xs" style="margin-left: 5px;"  href="#"onclick="del(\'' + index + '\')"><i class="fa fa-remove"></i>清空</a></div>'
                //         // } else {
                //         //     html = '<div style="width: 100px;"><a class="btn btn-success btn-xs" href="#"onclick="sumex(\'' + index + '\')"><i class="fa fa-edit"></i>提交</a><a class="btn btn-danger btn-xs" style="margin-left: 5px;" disabled="true" href="#"onclick="del(\'' + index + '\')"><i class="fa fa-remove"></i>清空</a></div>'
                //         // }
                //         return html;
                //     }
                // }
            ]
        };
        $.table.init(options);
    }

    function table_add() {
        if ($("#years").val() == '' || $("#months").val() == '') {
            $.modal.alertWarning('请选择日期！');
            return false
        }
        $("#myModal6").click();
        $("#year").val($("#years").val());
        $("#month").val($("#months").val());
        queryRegionList();
    }

    function readOnly() {
        var count;
        $.ajax({
            url: prefix + '/readOnly',
            async: false,
            data: {
                companyId: $("#companyId").val(),
                proId: $("#proId").val(),
                buildingId: $("#buildingId").val()
            },
            type: 'post',
            success: function (data) {
                count=data;
            }
        })
        return count;
    }

    function submit() {
        var data = [];
        for (var index = 0; index < $("#bootstrap-table").bootstrapTable('getData').length; index++) {
            changeData(index);
            data.push({
                number: $("#" + 'number' + index).val(),
                containTaxUnivalent: $("#" + 'containTaxUnivalent' + index).val(),
                targetCost: $("#" + 'targetCost' + index).val(),
                changeCost: $("#" + 'changeCost' + index).val(),
                reviseCost: $("#" + 'reviseCost' + index).val(),
                changeIncome: $("#" + 'changeIncome' + index).val(),
                profitChange: $("#" + 'profitChange' + index).val(),
                inputTax: $("#" + 'inputTax' + index).val(),
                taxRate: $("#" + 'taxRate' + index).val(),
                cumulative: $("#" + 'cumulative' + index).val(),
                theory: $("#" + 'theory' + index).val(),
                surplus: $("#" + 'surplus' + index).val(),
                allowance: $("#" + 'allowance' + index).val(),
                year: $("#year").val(),
                month: $("#month").val(),
                companyId: $("#companyId").val(),
                proId: $("#proId").val(),
                buildingId: $("#buildingId").val(),
                summaryId: $("#bootstrap-table").bootstrapTable('getData')[index].summaryId,
                codeId: $("#bootstrap-table").bootstrapTable('getData')[index].codeId,
                summaryMonthId: $("#bootstrap-table").bootstrapTable('getData')[index].summaryMonthId,
                currentNumber: $("#" + 'currentNumber' + index).val(),
                currentUnivalent: $("#" + 'currentUnivalent' + index).val(),
                currentTotal: $("#" + 'currentTotal' + index).val(),
                currentTheoryNumber: $("#" + 'currentTheoryNumber' + index).val(),
                currentTheoryTotal: $("#" + 'currentTheoryTotal' + index).val(),
                currentChangeCost: $("#" + 'currentChangeCost' + index).val(),
                currentChangeIncome: $("#" + 'currentChangeIncome' + index).val(),
                currentTheoryUnivalent: $("#" + 'currentTheoryUnivalent' + index).val()
            });
        }

        $.ajax({
            url: prefix + '/save',
            data: JSON.stringify(data),
            contentType: "application/json;charset=utf-8",
            type: 'post',
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
            },
            success: function (data) {
                $.modal.closeLoading();
                if (data.code == 0) {
                    $.modal.alertSuccess('提交成功');
                    $("#bootstrap-table").bootstrapTable('refresh');
                } else {
                    $.modal.alertError('提交失败');
                    return false
                }
            }
        })
    }

    // function del(index) {
    //     $("#" + 'number' + index).click();
    //     var data = {
    //         summaryId: summaryId,
    //         codeId: codeId
    //     }
    //     if (data.summaryId != null && data.codeId != null) {
    //         $.modal.confirm("是否要删除这一行数据?", function () {
    //             $.ajax({
    //                 url: prefix + '/remove',
    //                 data: data,
    //                 type: 'post',
    //                 success: function (data) {
    //                     if (data.code == 0) {
    //                         $.modal.alertSuccess('删除成功');
    //                         $("#bootstrap-table").bootstrapTable('refresh');
    //                     } else {
    //                         $.modal.alertError('删除失败');
    //                         return false
    //                     }
    //                 }
    //             })
    //         });
    //     }
    //
    // }
    // function sumex(index) {
    //     $("#" + 'number' + index).click();
    //     var data = {
    //         number: $("#" + 'number' + index).val(),
    //         containTaxUnivalent: $("#" + 'containTaxUnivalent' + index).val(),
    //         targetCost: $("#" + 'targetCost' + index).val(),
    //         changeCost: $("#" + 'changeCost' + index).val(),
    //         reviseCost: $("#" + 'reviseCost' + index).val(),
    //         changeIncome: $("#" + 'changeIncome' + index).val(),
    //         profitChange: $("#" + 'profitChange' + index).val(),
    //         inputTax: $("#" + 'inputTax' + index).val(),
    //         taxRate: $("#" + 'taxRate' + index).val(),
    //         cumulative: $("#" + 'cumulative' + index).val(),
    //         theory: $("#" + 'theory' + index).val(),
    //         surplus: $("#" + 'surplus' + index).val(),
    //         allowance: $("#" + 'allowance' + index).val(),
    //         year: $("#year").val(),
    //         month: $("#month").val(),
    //         companyId: $("#companyId").val(),
    //         proId: $("#proId").val(),
    //         buildingId: $("#buildingId").val(),
    //         summaryId: summaryId,
    //         codeId: codeId,
    //         summaryMonthId: summaryMonthId,
    //         currentNumber: $("#" + 'currentNumber' + index).val(),
    //         currentUnivalent: $("#" + 'currentUnivalent' + index).val(),
    //         currentTotal: $("#" + 'currentTotal' + index).val(),
    //         currentTheoryNumber: $("#" + 'currentTheoryNumber' + index).val(),
    //         currentTheoryTotal: $("#" + 'currentTheoryTotal' + index).val(),
    //         currentChangeCost: $("#" + 'currentChangeCost' + index).val(),
    //         currentChangeIncome: $("#" + 'currentChangeIncome' + index).val()
    //     };
    //     $.ajax({
    //         url: prefix + '/save',
    //         data: data,
    //         type: 'post',
    //         success: function (data) {
    //             if (data.code == 0) {
    //                 $.modal.alertSuccess('提交成功');
    //                 $("#bootstrap-table").bootstrapTable('refresh');
    //             } else {
    //                 $.modal.alertError('提交失败');
    //                 return false
    //             }
    //         }
    //     })
    // }

    //数量number
    //含税单价containTaxUnivalent
    //目标成本targetCost
    //变动成本changeCost
    //修订成本reviseCost
    //变动收入changeIncome
    //利润变动profitChange
    //进项税inputTax
    //税率taxRate
    //截至本期累计cumulative
    //截至本期理论theory
    //截至本期结余surplus
    //余量allowance
    //当期数量currentNumber
    //当期单价currentUnivalent
    //当期总价currentTotal
    //当期理论数量currentTheoryNumber
    //当期理论总价currentTheoryTotal
    //  changeCost;
    //  changeIncome;
    function changeData(index) {
            $("#" + 'number' + index).click();
        if (changeCost == undefined) {
            changeCost = 0;
        }
        if (changeIncome == undefined) {
            changeIncome = 0;
        }
        if (cumulative == undefined) {
            cumulative = 0;
        }
        if (cumulative == undefined) {
            cumulative = 0;
        }
        if (theory == undefined) {
            theory = 0;
        }
        $("#" + 'currentTheoryUnivalent' + index).val(Number($("#" + 'containTaxUnivalent' + index).val()));
        $("#" + 'currentTotal' + index).val((Number($("#" + 'currentNumber' + index).val()) * Number($("#" + 'currentUnivalent' + index).val())).toFixed(2));
        $("#" + 'currentTheoryTotal' + index).val((Number($("#" + 'currentTheoryNumber' + index).val()) * Number($("#" + 'currentTheoryUnivalent' + index).val())).toFixed(2));
        $("#" + 'targetCost' + index).val((Number($("#" + 'containTaxUnivalent' + index).val()) * Number($("#" + 'number' + index).val())).toFixed(2));
        $("#" + 'inputTax' + index).val((Number($("#" + 'targetCost' + index).val()) - Number($("#" + 'targetCost' + index).val()) / (1 + Number($("#" + 'taxRate' + index).val()) / 100)).toFixed(2));
        if (Number(summaryMonthId) != 0) {
            $("#" + 'cumulative' + index).val(Number($("#" + 'currentTotal' + index).val()) - Number(currentTotal) + Number(cumulative));
            $("#" + 'theory' + index).val(Number($("#" + 'currentTheoryTotal' + index).val()) - Number(currentTheoryTotal) + Number(theory));
            $("#" + 'changeCost' + index).val(Number(changeCost) + Number($("#" + 'currentChangeCost' + index).val() - Number(currentChangeCost)));
            $("#" + 'changeIncome' + index).val(Number(changeIncome) + Number($("#" + 'currentChangeIncome' + index).val() - Number(currentChangeIncome)));
        } else {
            $("#" + 'cumulative' + index).val(Number($("#" + 'currentTotal' + index).val()) + Number(cumulative));
            $("#" + 'theory' + index).val(Number($("#" + 'currentTheoryTotal' + index).val()) + Number(theory));
            $("#" + 'changeCost' + index).val(Number(changeCost) + Number($("#" + 'currentChangeCost' + index).val()));
            $("#" + 'changeIncome' + index).val(Number(changeIncome) + Number($("#" + 'currentChangeIncome' + index).val()));
        }
        $("#" + 'reviseCost' + index).val(Number($("#" + 'targetCost' + index).val()) + Number($("#" + 'changeCost' + index).val()));
        $("#" + 'profitChange' + index).val(Number($("#" + 'changeIncome' + index).val()) - Number($("#" + 'changeCost' + index).val()));
        $("#" + 'surplus' + index).val(Number($("#" + 'theory' + index).val()) - Number($("#" + 'cumulative' + index).val()));
        $("#" + 'allowance' + index).val(Number($("#" + 'reviseCost' + index).val()) - Number($("#" + 'cumulative' + index).val()));

        if ($("#number" + index).val() == '') {
            $("#number" + index).val(Number(0));
        }
        if ($("#currentChangeCost" + index).val() == '') {
            $("#currentChangeCost" + index).val(Number(0));
        }
        if ($("#containTaxUnivalent" + index).val() == '') {
            $("#containTaxUnivalent" + index).val(Number(0));
        }
        if ($("#currentChangeIncome" + index).val() == '') {
            $("#currentChangeIncome" + index).val(Number(0));
        }
        if ($("#taxRate" + index).val() == '') {
            $("#taxRate" + index).val(Number(0));
        }
        if ($("#currentNumber" + index).val() == '') {
            $("#currentNumber" + index).val(Number(0));
        }
        if ($("#currentUnivalent" + index).val() == '') {
            $("#currentUnivalent" + index).val(Number(0));
        }
        if ($("#currentTheoryUnivalent" + index).val() == '') {
            $("#currentTheoryUnivalent" + index).val(Number(0));
        }
        if ($("#currentTheoryNumber" + index).val() == '') {
            $("#currentTheoryNumber" + index).val(Number(0));
        }
    }


</script>
</body>
</html>